//
//  TableViewCell.m
//  Tableviewcell自适应
//
//  Created by 郭明皓 on 16/6/21.
//  Copyright © 2016年 郭明皓. All rights reserved.
//

#import "TableViewCell.h"

@implementation uicollectionviews


@end
@implementation TableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (!(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) return nil;
    
    self.images = [[UIImageView alloc]initWithFrame:CGRectZero];
    [self.contentView addSubview:_images];
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.sectionInset = UIEdgeInsetsMake(10, 20, 10, 20);
    layout.itemSize = CGSizeMake(100, 100);
    layout.minimumInteritemSpacing = 5;
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    self.collectview = [[uicollectionviews alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
    [self.collectview registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:CollectionViewCellIdentifier];
    self.collectview.backgroundColor = [UIColor yellowColor];
    self.collectview.showsHorizontalScrollIndicator = NO;
    [self.contentView addSubview:_collectview];

    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.images.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 150);
    self.collectview.frame = CGRectMake(0, 150, self.contentView.frame.size.width, self.contentView.frame.size.height - 150);
}
- (void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource, UICollectionViewDelegate>)dataSourceDelegate indexPath:(NSIndexPath *)indexPath
{
    self.collectview.dataSource = dataSourceDelegate;
    self.collectview.delegate = dataSourceDelegate;
    self.collectview.indexPaths = indexPath;
    
    [self.collectview reloadData];
}

@end
